package com.agent.history.mapper;

import com.agent.commons.other.MessageHistory;
import com.agent.history.dataobject.ConversationBaseDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface  ConversationMapper {

    /**
     * 插入新建会话id
     * @param message
     */
    @Insert( "insert into conversation(conversationId,conversationName,userId) values(#{conversationId},#{conversationName},#{userId})")
    int addConversation(MessageHistory message);

     /**
     * 检查会话id 是否属于用户
     * @param userId
     * @param conversationId
     * @return
     */
     @Select("select count(*) from conversation where conversationId=#{conversationId} and userId=#{userId}")
     int  checkConversationIdWithUserId(String userId,String conversationId);


    /**
     * 获取用户会话列表
     * @param userId
     * @return
     */
    @Select("select conversationId,conversationName from conversation where userId=#{userId}")
     List<ConversationBaseDO> getConversationMember(String userId);
}
